package com.oocl.o2o.client.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.oocl.o2o.client.dao.ReceiverInfoDao;
import com.oocl.o2o.client.entity.Customer;
import com.oocl.o2o.client.entity.ReceiverInfo;
import com.oocl.o2o.client.service.ReceiverInfoService;
import com.oocl.o2o.client.vo.ReceiverInfoVO;

/**
 * 
 * @author HEHA4
 *
 *
 */

@Service(value="receiverInfoServiceImpl")
public class ReceiverInfoServiceImpl implements ReceiverInfoService {
	
	@Resource(name="receiverInfoDaoImpl")
	private ReceiverInfoDao receiverInfoDao;
	@Override
	@Transactional
	public ReceiverInfo add(ReceiverInfoVO r ,Customer customer) {
		ReceiverInfo receiverInfo = new ReceiverInfo();
		receiverInfo.setAddress(r.getAddress());
		receiverInfo.setCustomer(customer);
		receiverInfo.setName(r.getName());
		receiverInfo.setPhone(r.getPhone());
		return receiverInfoDao.add(receiverInfo);
	}

	@Override
	@Transactional
	public ReceiverInfo update(ReceiverInfo r) {
		
		return receiverInfoDao.update(r);
	}

	@Override
	@Transactional
	public ReceiverInfo delete(String id) {
		return receiverInfoDao.delete(id);
	}

	@Override
	public ReceiverInfo findById(String id) {
		
		return receiverInfoDao.findById(id);
	}

	@Override
	public List<ReceiverInfo> findByCustomerId(String id) {
		
		return receiverInfoDao.findByCustomerId(id);
	}

}
